home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / oper_sys / emerald / emrldsys.lha / Kernel / Em / vax.kstub.4s < prev    next >
Encoding:
Text File  |  1990-08-17  |  16.7 KB  |  583 lines

  1.  
  2.  #       Definition of the compiled code to kernel calls code.
  3.  #       Origin:  Eric Jul, 1986-03-01.
  4.  #       
  5.  # /*  C O P Y R I G H T   N O T I C E :                                    */
  6.  # /* Copyright 1986 Eric Jul and Norm Hutchinson.  May not be used for any */
  7.  # /* purpose without written permission from the authors.            */
  8.  
  9.  #       This defines a number of simple code pieces called by compiled code.
  10.  
  11. sinclude(xkerneldefine)
  12.  
  13.         .globl      _TaskQ
  14.         .globl      _currentSSP
  15.         .globl      _kernelsp
  16.         .globl      _ReturnOffStack
  17.         .globl      _BadJump
  18.         .text
  19. LL0:
  20.  
  21. include(../h/vax.regdefs.h)
  22. include(../h/consts.h)
  23.  
  24. define(dosaveregs,
  25.         moval       SS_regs `(' regs_ssp `)'`,'scratch
  26.         movq        r1`,'(scratch)+
  27.         movq        r3`,'(scratch)+
  28.         movq        r5`,'(scratch)+
  29.         movq        r7`,'(scratch)+
  30.         movl        r9`,'(scratch)+
  31.         movq        r11`,'(scratch)+
  32.         movq        r13`,'(scratch)
  33.         movl        _kernelsp`,'sp
  34.                                         )
  35.  
  36. define(restoreregs,
  37.         movl        _currentSSP`,'regs_ssp
  38.         moval       SS_regs `(' regs_ssp `)' `,' scratch
  39.         movq        (scratch)+`,'r1
  40.         movq        (scratch)+`,'r3
  41.         movq        (scratch)+`,'r5
  42.         movq        (scratch)+`,'r7
  43.         movl        (scratch)+`,'r9
  44.         movq        (scratch)+`,'r11
  45.         movq        (scratch)`,'r13
  46. urun:   .globl      urun
  47.         rsb
  48.                                         )
  49.  
  50. define(c_restoreregs,
  51.         movl        _currentSSP`,'regs_ssp
  52.         moval       SS_regs `(' regs_ssp `)' `,' scratch
  53.         movq        (scratch)+`,'r1
  54.         movq        (scratch)+`,'r3
  55.         movq        (scratch)+`,'r5
  56.         movq        (scratch)+`,'r7
  57.         movl        (scratch)+`,'r9
  58.         movq        (scratch)+`,'r11
  59.         movq        (scratch)`,'r13
  60.         rsb
  61.                                         )
  62.  
  63.  # All Emerald kernel entry points are defined using the following macros
  64. define(ementry,_$1: .globl   _$1)
  65. define(emexit,rsb)
  66.  
  67. define(DataBrand,0)         # copied from ecTypes.h!!!
  68. # For calling C procedures
  69. define(call_c,
  70.         `dosaveregs'
  71.         `ifelse($1,3,
  72.         pushl       arg3
  73.         pushl       arg2
  74.         pushl       arg1)
  75.         ifelse($1,2,
  76.         pushl       arg2
  77.         pushl       arg1)
  78.         ifelse($1,1,
  79.         pushl       arg1)'
  80.         calls       `$'$1`,'_$2
  81.         `ifelse($3,1,
  82.         movl        r0`,'arg1)'
  83.     `c_restoreregs'
  84.         )
  85.  
  86. define(call_k,
  87.         movl    `$' DataBrand`,' SS_resultBrand `(' regs_ssp `)'
  88.         `dosaveregs'
  89.         `ifelse($1,3,
  90.         pushl       arg3
  91.         pushl       arg2
  92.         pushl       arg1)
  93.         ifelse($1,2,
  94.         pushl       arg2
  95.         pushl       arg1)
  96.         ifelse($1,1,
  97.         pushl       arg1)'
  98.         calls       `$'$1`,'_$2
  99.         `ifelse($3,1,
  100.         movl        r0`,'arg1)'
  101.         jmp         kernel_exit
  102.         )
  103.  
  104.  ########################################################################
  105.  #      Kernel exit code.
  106.  #      This is the common exit point for all calls to the C part of
  107.  #      the kernel
  108.  ########################################################################
  109.  
  110.  
  111.         .stabs  "kernel_exit:F1",0x24,0,4,_kernel_exit
  112. _kernel_exit:
  113.         .globl      _kernel_exit
  114.         .word       0
  115. kernel_exit:
  116.         .globl      kernel_exit
  117. ifdef(xkernel,
  118. `    calls        $0, _doScheduling',
  119. `       cmpl        $ _TaskQ,_TaskQ         # Handle kernel tasks first.
  120.         jneq        cycle_mainLoop          # 
  121.         tstl        _currentSSP             # if there is a process, run it
  122.         jneq        runit                   #
  123.         calls       $0,_ensureRunning       # make one the current one
  124.         cmpl        $ _TaskQ,_TaskQ         # To prevent losing preemption
  125.         jneq        cycle_mainLoop          # signals that arrived
  126.                                             # AFTER the last cycle of the
  127.                                             # main loop but before the
  128.                                             # resetting of the prempt flag.
  129. ')
  130.  
  131. runit:                                      # Run the process.
  132. ifdef(xkernel,
  133. `    movl        sp, _kernelsp',)
  134.         restoreregs
  135.         # won't ever return here
  136.         calls       $0,_abort               
  137.         
  138. ifdef(xkernel,,`
  139. cycle_mainLoop:
  140.         calls       $0,_MainLoop            # Cycle the task queue
  141.         jmp         kernel_exit             # Retry kernel exit
  142. ')
  143.  ########################################################################
  144.  #      ReturnOffStack
  145.  #      Processes return to here when they return off the bottom of a
  146.  #      Stack Segment.
  147. _ReturnOffStack:                            #
  148.         call_k(0, DoReturnOffStack)
  149.  
  150.  ########################################################################
  151.  #      A local invocation was attempted to a non-resident piece of code
  152.  #      This usually indicates a kernel error.
  153.  #      The activation record is backed up (so the kernel can print
  154.  #      debug information about where the fault occurred).
  155.  #      The kernel is called -- and will abort.
  156. _BadJump:
  157.         # Pop back to calling environment.
  158.         movl        (sp)+, r0
  159.         movq        (sp)+, regs_b
  160.         movl        (sp)+, regs_l
  161.         movl        r0, -(sp)
  162.         call_k(0, BadJumpOccurred)
  163.         
  164.  ########################################################################
  165.  #      The kernel entry points follow.
  166.  
  167.  # The following is for dbx use only.
  168.         .stabs  "kernel_entry:F1",0x24,0,4,_kernel_entry
  169. _kernel_entry:
  170.         .globl      _kernel_entry
  171.         .word       0
  172.  
  173.  ########################################################################
  174.  #      Process preemption, loops and routine entry.
  175.  ########################################################################
  176.  
  177.         ementry(em_loopPreempt)
  178.         call_k(0, LoopPreempt)
  179.         emexit
  180.  
  181.  ########################################################################
  182.  #      stackCheck(stackMax)
  183.  #      Insure that the current stack segment allows for stackMax more
  184.  #      space to be allocated.
  185.  #      Usually, the compiler would generate code to do the stack check
  186.  #      and only call this routine, if the check failed.
  187.  #      The stack check could fail for two reasons:
  188.  #          The stack is too small and needs to be extended.
  189.  #          The process is to be preempted and its stack has been
  190.  #          cut down to cause it to fail the next stack check and thus
  191.  #          give up the CPU by calling the kernel.
  192.  ########################################################################
  193.  
  194.         ementry(em_stackCheck)
  195.         call_k(1,StackCheck)
  196.         emexit
  197.         
  198.  
  199.  ########################################################################
  200.  #      Operation entry and exit
  201.  ########################################################################
  202.  
  203.         ementry(em_invoke)
  204.         movl        regs_b, arg3
  205.         movl        (sp)+, scratch
  206.         movl        (sp)+, regs_b
  207.         addl2       $ 8, sp
  208.         movl        scratch, -(sp)  
  209. #        clrq        -(sp)
  210.         call_k(3, Invoke)
  211.         emexit
  212.  
  213.         ementry(em_invokeWithMove)
  214.         #new sequence
  215.         movl        regs_b, arg3    # callee GODP
  216.         movl        12(sp), regs_b  # caller GODP
  217.         movl        8(sp), 20(sp)   # return addr
  218.         movq        (sp), 12(sp)    # move and visit mask
  219.         addl2       $12, sp         # clear away junk
  220.         call_k(3, InvokeWithMove)
  221.         emexit
  222.  
  223.         #old sequence
  224.         #addl2       $ 8, sp
  225.         #movl        regs_b, arg3
  226.         #movl        (sp)+, scratch
  227.         #movl        (sp)+, regs_b
  228.         #addl2       $ 8, sp
  229.         #movl        scratch, -(sp)  
  230.         #call_k(3, Invoke)
  231.         #emexit
  232.  
  233.         ementry(em_initiallyDone)
  234.         call_k(0, InitiallyDone)
  235.         emexit
  236.  
  237.         ementry(em_endRecovery)
  238.         call_k(0, InitiallyDone)
  239.         emexit
  240.  
  241.  ########################################################################
  242.  #      Creation
  243.  ########################################################################
  244.  
  245.         ementry(em_globalCreate)
  246.         call_k(1,Create)
  247.         emexit
  248.  
  249.     ementry(em_globalCreateSized)
  250.         call_k(2,CreateSized)
  251.         emexit
  252.  
  253.         ementry(em_localCreate)
  254.         call_k(1,LocalCreate)
  255.         emexit
  256.  
  257.         ementry(em_localQuickCreate)
  258.         call_c(1,LocalQuickCreate)
  259.         emexit
  260.  
  261.         ementry(em_localCreateSized)
  262.         call_k(2,LocalCreateSized)
  263.         emexit
  264.  
  265.         ementry(em_localQuickCreateSized)
  266.         call_c(2,LocalQuickCreateSized)
  267.         emexit
  268.  
  269.  #      globalCreateVector(codePtr, sizeInBytes, upb)
  270.         ementry(em_globalCreateVector)
  271.         call_k(3,GlobalCreateVector)
  272.         emexit
  273.  
  274.  #      globalCreateVectorLiteral(codePtr, sizeOfEachElement, nElements)
  275.         ementry(em_globalCreateVectorLiteral)
  276.         call_k(3,CreateImmutableVectorLiteral)
  277.         emexit
  278.  
  279.  #      em_localCreateVector(codePtr, sizeInBytes, upb)
  280.         ementry(em_localCreateVector)
  281.         call_k(3,LocalCreateVector)
  282.         emexit
  283.  
  284.  #      localCreateVectorLiteral(codePtr, sizeOfEachElement, nElements)
  285.         ementry(em_localCreateVectorLiteral)
  286.         call_k(3,CreateImmutableVectorLiteral)
  287.         emexit
  288.  
  289.  #      em_createString(sizeInBytes)
  290.         ementry(em_createString)
  291.         call_c(1,CreateString)
  292.         emexit
  293.  
  294.  
  295.  ########################################################################
  296.  #      Not implemented
  297.  ########################################################################
  298.  
  299.         ementry(em_notimpl)
  300.         call_k(0,NotImplemented)
  301.  
  302.  ########################################################################
  303.  #      Monitors and conditions.
  304.  ########################################################################
  305.         ementry(em_monEntry)
  306.         call_k(1,MonitorEntry)
  307.         emexit
  308.  
  309.         ementry(em_monExit)
  310.         tstl        MonitorLock_waiting (arg1)
  311.         jeql        mE1
  312.         call_k(1,MonitorExit)
  313.         emexit
  314. mE1:
  315.         clrl        (arg1)
  316.         emexit
  317.  
  318.  
  319.         ementry(em_condInit)
  320.         call_k(1,CondInit)
  321.         emexit
  322.  
  323.  
  324.         ementry(em_condWait)
  325.         call_k(2,WaitCond)
  326.         emexit
  327.  
  328.         
  329.         ementry(em_condSignal)
  330.         cmpl        CondOD_theLock (arg2), arg1
  331.         jneq         csIllegal1
  332.         tstl        CondOD_waiting (arg2)
  333.         jeql        csNoWaiting
  334. csIllegal1:
  335.         call_k(2,SignalCond)
  336. csNoWaiting:
  337.         emexit
  338.  
  339.         
  340.         ementry(em_condSignalAndExit)
  341.         cmpl        CondOD_theLock (arg2), arg1
  342.         jneq        csIllegal2
  343.         tstl        CondOD_waiting (arg2)
  344.         jeql        _em_monExit
  345. csIllegal2:         # let the kernel handle this
  346.         call_k(2,SignalAndExitCond)
  347.         emexit
  348.  
  349.         
  350.         ementry(em_condAwaiting)
  351.         tstl        CondOD_waiting (arg1)
  352.         movpsl      arg1
  353.         extv        $ 2,$ 1,arg1,arg1
  354.         incl        arg1
  355.         emexit
  356.  
  357.  
  358.  #        old version of em_condAwaiting
  359.  #        clrl        scratch
  360.  #        tstl        CondOD_waiting (arg1)
  361.  #        jeql        csQueueEmpty
  362.  #        incl        scratch
  363.  #csQueueEmpty:
  364.  #        movl        scratch,arg1
  365.  #        emexit
  366.  
  367.  
  368.  ########################################################################
  369.  #      Location dependent operations
  370.  ########################################################################
  371.         
  372.         ementry(em_isFixed)
  373.         call_k(2,IsFixed)
  374.         emexit
  375.  
  376.         
  377.         ementry(em_unFix)
  378.         call_k(2,UnFix)
  379.         emexit
  380.  
  381.         
  382.         ementry(em_fix)
  383.         call_k(2,Fix)
  384.         emexit
  385.  
  386.         ementry(em_locate)
  387.         call_k(2,Locate)
  388.         emexit
  389.  
  390.         ementry(em_move)
  391.         call_k(2, Move)
  392.         emexit
  393.         
  394.  ########################################################################
  395.  #      delay, waitUntil
  396.  ########################################################################
  397.         
  398.         ementry(em_delay)
  399.         call_k(1,Delay)
  400.         emexit
  401.         
  402.         ementry(em_waitUntil)
  403.         call_k(1,WaitUntil)
  404.         emexit
  405.  
  406.  ########################################################################
  407.  #      Assertion failure (caused by erroneous user program)
  408.  ########################################################################
  409.  
  410.         ementry(em_assertionFailure)
  411.         call_k(0,AssertFailed)
  412.         emexit
  413.  
  414.         ementry(em_returnAndFail)
  415.         call_k(0,ReturnAndFail)
  416.         emexit
  417.  
  418.  ########################################################################
  419.  #      InvokeAssumption failure (caused by system error)               #
  420.  ########################################################################
  421.         # params (fG, fAbConPtr, fB)
  422.         ementry(em_invokeAssumptionFailure)
  423.         call_k(3,InvokeAssumptionFailed)
  424.         emexit
  425.  
  426.  ########################################################################
  427.  #      BadSignal handling (caused by NIL references)
  428.  ########################################################################
  429.         .data
  430. _BadSigPC:
  431.         .globl      _BadSigPC
  432.         .align      2
  433.         .long       0
  434.         .align      2
  435.         .text
  436. _BadSigJumpPoint:
  437.         .globl      _BadSigJumpPoint
  438.         movl        _BadSigPC, -(sp)
  439.         call_k(0,BadSignalOccurred)
  440.         emexit
  441.  
  442.  ########################################################################
  443.  #      Line number tracing
  444.  ########################################################################
  445.  #      Note: this entry point may be called from anywhere between two
  446.  #      Emerald statements and should save and restore all registers
  447.  
  448.         ementry(em_trace)
  449.         movl        r0,_registerSave
  450.         moval       _registerSave+4,r0
  451.         movq        r1,(r0)+
  452.         movq        r3,(r0)+
  453.         movq        r5,(r0)+
  454.         movq        r7,(r0)+
  455.         movq        r9,(r0)+
  456.         movq        r11,(r0)+
  457.         movq        r13,(r0)
  458.         movl        _kernelsp,sp
  459.         calls       $0,_LineNumber
  460.         moval       _registerSave+4,r0
  461.         movq        (r0)+,r1
  462.         movq        (r0)+,r3
  463.         movq        (r0)+,r5
  464.         movq        (r0)+,r7
  465.         movq        (r0)+,r9
  466.         movq        (r0)+,r11
  467.         movq        (r0),r13
  468.         movl        _registerSave,r0
  469.         emexit
  470.  
  471.  
  472.  ########################################################################
  473.  #      View changes, Conformity, and Restrict
  474.  ########################################################################
  475.  
  476.         ementry(em_changeviewptr)
  477.         call_k(2,ChangeViewPtr)
  478.         emexit
  479.         
  480.     ementry(em_tryviewptr)
  481.     call_k(3,ViewPtr)
  482.     emexit
  483.     
  484.         ementry(em_conform)
  485.         call_k(2,Conform)
  486.         emexit
  487.         
  488.         ementry(em_restrictptr)
  489.         call_k(3, RestrictPtr)
  490.         emexit
  491.  
  492.  ########################################################################
  493.  #      Node operations                                                 #
  494.  ########################################################################
  495.  
  496.         ementry(em_getAllNodes)
  497.         call_k(0,Node_getAllNodes)
  498.         emexit
  499.  
  500.         ementry(em_getActiveNodes)
  501.         call_k(0,Node_getActiveNodes)
  502.         emexit
  503.  
  504.         ementry(em_getNodeInformation)
  505.         call_k(1,Node_getNodeInformation)
  506.         emexit
  507.         
  508.         ementry(em_setNodeEventHandler)
  509.         call_k(2,Node_setNodeEventHandler)
  510.         emexit
  511.         
  512.         ementry(em_removeNodeEventHandler)
  513.         call_k(2,Node_removeNodeEventHandler)
  514.         emexit
  515.  
  516.  ########################################################################
  517.  
  518.         ementry(em_getStdOut)
  519.         call_k(0,GetStdOut)
  520.         emexit
  521.  
  522.         ementry(em_getStdIn)
  523.         call_k(0,GetStdIn)
  524.         emexit
  525.         
  526.         ementry(em_getMyStdOut)
  527.         call_k(0,GetMyStdOut)
  528.         emexit
  529.         
  530.         ementry(em_getMyStdIn)
  531.         call_k(0,GetMyStdIn)
  532.         emexit
  533.  
  534. #    em#####entry(emx_nextevent)
  535. #    call_k(1,EMXReadEvent)
  536. #    emexit
  537.  
  538.     ementry(em_getName)
  539.     call_k(0,Node_getName)
  540.     emexit
  541.  
  542.  ########################################################################
  543.  #      I/O
  544.  ########################################################################
  545.  
  546.         ementry(em_read)
  547.         call_k(2,StreamRead)
  548.         emexit
  549.  
  550.         ementry(em_write)
  551.         call_k(3,StreamWrite)
  552.         emexit
  553.         
  554.         ementry(em_closeInStream)
  555.         call_k(1,CloseInStream)
  556.         emexit
  557.         
  558.         ementry(em_closeOutStream)
  559.         call_k(1,CloseOutStream)
  560.         emexit
  561.  
  562.  ########################################################################
  563.  #      Checkpoint
  564.  ########################################################################
  565.  
  566.         ementry(em_checkpoint)
  567.         call_k(3,Checkpoint)
  568.         emexit
  569.  
  570.  ########################################################################
  571.  #      ownName and ownType
  572.  ########################################################################
  573.  
  574.     ementry(em_ownName)
  575.     call_k(1,OwnName)
  576.     emexit
  577.     
  578.     ementry(em_ownType)
  579.     call_k(1,OwnType)
  580.     emexit
  581.     
  582.     
  583.